home *** CD-ROM | disk | FTP | other *** search
- Path: colossus.holonet.net!russell
- From: russell@news.mdli.com (Russell Blackadar)
- Newsgroups: comp.object,comp.lang.c++,comp.ai.alife,sci.comp-aided
- Subject: Re: [Q] Growing Objects
- Followup-To: comp.object,comp.lang.c++,comp.ai.alife,sci.comp-aided
- Date: 19 Jan 1996 04:07:04 GMT
- Organization: HoloNet National Internet Access System: 510-704-1058/modem
- Message-ID: <4dn5d8$lor@colossus.holonet.net>
- References: <30FE8297.41C6@bme.jhu.edu>
- NNTP-Posting-Host: jubal.mdli.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- Harold Bien (hbien@bme.jhu.edu) wrote:
- [much deleted]
- : The class Cell has a function Run() which takes no arguments but
- : calls another function through a pointer to a member function. Then,
- : when that member function runs, it updates a variable 'age' and checks
- : to see if it is mature. If so, then it will change the pointer to point
- : to another function. Here's what it will look like:
-
- That idea seems fine to me. *The* classic use of member-function
- pointers is to dispatch to different methods depending on some state
- of the object (e.g. "age" in your case).
-
- [code deleted, except...]
-
- : RunFunc=Run_PreMature; /* Point RunFunc to PreMature() function */
- ^^^^^^^^^^^^^
- and
-
- : if (age>=4) RunFunc=Run_PostMature; ...
- ^^^^^^^^^^^^^^
-
- You should put a "&" in front of these, to comply with the standard.
- Some compilers let you get away without it, but who knows if you'll
- always use the same compiler.
-
- BTW, you might find // comments to your liking, in the above.
- --
- Russell Blackadar, russell@mdli.com
-